<?php

//echo "pase";
require_once 'jq-config2.php';
//require_once ('/Applications/MAMP/htdocs/HS/jqSuitePHP_4_1_2_2/jq-config.php');
// include the jqGrid Class

require_once ABSPATH."php/jqGrid.php";
// include the driver class
require_once ABSPATH."php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");


// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query

// Write the SQL Query

$grid->SelectCommand = "SELECT idUsuarioHCD,pathFoto,Usuario,Password,Nombre,Apellido,Sexo,Edad,Email,NumDocUsuario,idConsultorio, 
idJerarquia,idEspecialidad FROM usuarioshcd" ;

$grid->table = 'usuarioshcd'; 
//echo $grid->SelectCommand ;
// Set the table to where you update the data
//$grid->table = 'paciente';
// Set output format to json
$grid->dataType = 'json';
// Let the grid create the model

$grid->setColModel();

$grid->setUrl("Grid/griduser.php");

// Set the url from where we obtain the data
// Set the url from where we obtain the data
// Set some grid options
$grid->setGridOptions(array(
        "caption"=>"Usuarios", 
        "width"=>1000,
        "height"=>200,  
    "rowNum"=>20,
    "rowList"=>array(20,40,60),
    "shrinkToFit"=>false,
    "sortname"=>"idUsuarioHCD"
));

$grid->setColProperty('idUsuarioHCD', array("label"=>"ID", "width"=>50));
$grid->setColProperty('pathFoto', array("label"=>"Photo","search"=>false, "width"=>70,"formatter"=>"js:formatImage", "unformat"=>"js:unformatImage"));
$grid->setColProperty('Nombre', array("label"=>"Nombres", "width"=>120));
$grid->setColProperty('Apellido', array("label"=>"Apellido", "width"=>120));
$grid->setColProperty('Usuario', array("label"=>"Usuario", "width"=>120));
$grid->setColProperty('Edad', array("label"=>"Edad", "width"=>80));
$grid->setColProperty('idConsultorio', array("label"=>"Consultorio", "width"=>120));
$grid->setColProperty('idEspecialidad', array("label"=>"Especialidad", "width"=>120));
$grid->setColProperty('NumDocUsuario', array("label"=>"Documento", "width"=>120));
$grid->setColProperty('Sexo', array("label"=>"Sexo", "width"=>80));
$grid->setColProperty('Email', array("label"=>"e-mail", "width"=>200));
$grid->setColProperty('Password', array("label"=>"Password", "width"=>120));
$grid->setColProperty('idJerarquia', array("label"=>"Jerarquia", "width"=>100));

$grid->toolbarfilter = true; 
// Enable navigator

$pepe1 = <<<PEPE1
function formatImage(cellValue, options, rowObject) { 

        var imageHtml = "<img width='40px' height='40px' src='../" + cellValue + "' originalValue='" + cellValue + "' />";


return imageHtml; 
} 
function unformatImage(cellValue, options, cellObject) { 
    return $(cellObject.html()).attr("originalValue"); 
} 
function formatRating(cellValue, options, rowObject) { 
    var color = (parseInt(cellValue) > 0) ? "green" : "red"; 
    var cellHtml = "<span style='color:" + color + "' originalValue='" + 
                   cellValue + "'>" + cellValue + "</span>"; 
    return cellHtml; 
} 
function unformatRating(cellValue, options, cellObject) { 
    return $(cellObject.html()).attr("originalValue"); 
} 
PEPE1;
$grid->setJSCode($pepe1); 
//$grid->setJSCode($custom); 

$grid->navigator = true;
// Enable only editing
//$grid->setNavOptions('navigator', array("excel"=>false,"add"=>false,"edit"=>false,"del"=>false,"view"=>false));

$grid->setNavOptions('navigator', array("excel"=>true,"add"=>true,"edit"=>true,"del"=>true,"view"=>true, "search"=>true));

// Enjoy
$grid->renderGrid('#grid1','#pager',true, null, null, true,true);
// we set the select for ship city 

//$grid->setSelect("ShipCity", "SELECT DISTINCT ShipCity, ShipCity AS CityName FROM orders ORDER BY 2", false, false, true, array(""=>"All"))

$conn = null;

?> 
 


